'use strict';

module.exports = createUpdatedCollection;
function createUpdatedCollection(collectionA, objectB) {
 let result=[];
 let arr=objectB.value;
 
 for(let i=0;i<collectionA.length;i++){
  for(let j of arr){
    if(collectionA[i].key===j&&collectionA[i].count>=3){
      collectionA[i].count=collectionA[i].count-Math.floor(collectionA[i].count/3);
      
    }
  }
}

result.push(collectionA);
console.log(result[0]);
return result[0];

}
createUpdatedCollection( [
  {key: 'a', count: 3},
  {key: 'e', count: 7},
  {key: 'h', count: 11},
  {key: 't', count: 20},
  {key: 'f', count: 9},
  {key: 'c', count: 8},
  {key: 'g', count: 7},
  {key: 'b', count: 6},
  {key: 'd', count: 5}
],{value: ['a', 'd', 'e', 'f']});